package com.runtime.hongyunmanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.runtime.hongyunmanage.domain.Carousels;
import com.runtime.hongyunmanage.domain.vo.OrdersVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Locale;

@Mapper
public interface CarouselsMapper extends BaseMapper<Carousels> {
    List<Carousels> findAll();
//    Integer updateSortOrder(@Param("upId")Integer upId, @Param("sortOrder")Integer sortOrder);

//  void swapCarouselSortOrder(@Param("upId")Integer upId, @Param("downId")Integer downId);

    Carousels selectId(int id);


    int swapCarouselSortOrder(@Param("upId") int upId, @Param("downId") int downId, @Param("upSortOrder") int upSortOrder, @Param("downSortOrder") int downSortOrder);
    Integer updateDetail(@Param("id") Integer id,@Param("imageUrl")String imageUrl,@Param("description")String description,@Param("endDate")String endDate);
    int delete(int id);

        @Insert({
                "<script>",
                "INSERT INTO carousels (imageUrl, captionText, sortOrder,endDate,Date ,isActive, link) VALUES (#{filePath}, #{description}, #{sortOrder},#{endDate},#{Date},#{isActive}, #{link})",
                "</script>"
        })
        int addImageByType(@Param("filePath") String filePath, @Param("description") String description, @Param("sortOrder") int sortOrder,@Param("endDate") String endDate,@Param("Date") Date Date, @Param("isActive") int isActive, @Param("link") String link);

        // 新增查询最大 sortOrder 的方法
        @Select("SELECT MAX(sortOrder) FROM carousels")
        Integer findMaxSortOrder();


}
